package com.learn.datasource;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @create: 2023-04-17 22:52
 * @author: Mr.Du
 * --------------
 * @notes: 批的方式读取文本文件
 **/
public class BatchFromFile {
    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port", 8181);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(conf);
        String path = "./data/input/wordcount.txt";

        DataStreamSource<String> lines = env.readTextFile(path);

        int parallelism = lines.getParallelism();
        System.out.println("DataStreamSource<String> lines的并行度为：" + parallelism);

        lines.print();

        env.execute();

    }
}
